package com.toplabs.unashu.common;

import com.toplabs.unashu.common.utils.TopLabsUtils;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * @author toplabs
 * @since 2022/06/15
 * <p>This java file was created by toplabs in 2022/06/15.
 * The following is the description information about this file:</p>
 * <p>toplabs system constants</p>
 */
@SuppressWarnings("unused")
public class Constants {
    private Constants() {
    }

    public static final String USER_HOME_KEY = "user.dir";
    /**
     * User home dir path.
     */
    public static final String USER_HOME = rootPath();
    /**
     * Path separator.
     */
    public static final String SEPARATOR = File.separator;
    /**
     * File used to mark whether the system is installed.
     */
    public static final String MARK_FILE = ".mark";
    public static final String CONFIG_FILE_PATH = "config";
    public static final String STRING_EMPTY = "";
    public static final String MYSQL_CONFIG_FILE_NAME = "mysql.properties";
    public static final String MYSQL_URL_KEY = "url";
    public static final String MYSQL_USERNAME_KEY = "username";
    public static final String MYSQL_PASSWORD_KEY = "password";
    public static final String LOGIN_SESSION_KEY = "profile";
    public static final String ALGORITHM_NAME = "MD5";
    public static final int HASH_ITERATIONS = 1024;
    public static final String ENCRYPT_SALT = "1VJOQ78GPCMPFMVD3E0PLDOL5Q";
    public static final ThreadLocal<DateFormat> CRON_DATE_FORMAT = ThreadLocal.withInitial(() -> new SimpleDateFormat("ss mm HH dd MM ?"));
    public static final String TOPLABS_STORAGE_DIR = Constants.USER_HOME + SEPARATOR + ".toplabs" + SEPARATOR;
    public static final String INITIAL_SCHEMA_FILE = "initialize.sql";
    public static final String TASK_BEAN_NAME = "taskService";
    public static final String UNKNOWN = "unknown";
    public static final String MAPPER_LOCATIONS = "classpath:mapper/*.xml";
    public static final String APPLICATION_JSON = "application/json";
    public static final String RESPONSE_CONTENT_TYPE = "application/json; charset=utf-8";

    public static final String CACHE_PREFIX_ACCESS_TOKEN = "USER_ACCESS_TOKEN";
    public static final String CACHE_PREFIX_REFRESH_TOKEN = "USER_REFRESH_TOKEN";
    public static final String AUTH_TYPE_CREDENTIALS = "Credentials";
    public static final String AUTH_TYPE_REFRESH = "Refresh";
    public static final String HEADER_KEY_AUTHORIZATION = "access_token";
    public static final String HEADER_KEY_TIMESTAMP = "timestamp";
    public static final String HEADER_KEY_NONCE = "nonce";
    public static final String HEADER_KEY_SIGN = "sign";
    public static final String API_SAFE_BODY_KEY = "content";

    public static final Integer MSG_LOG_DELIVER_CONDUCT = 0; // 投递中
    public static final Integer MSG_LOG_DELIVER_SUCCESS = 1; // 投递成功
    public static final Integer MSG_LOG_DELIVER_FAILED = 2; // 投递失败
    public static final Integer MSG_LOG_DELIVER_CONSUME = 3; // 已消费

    public static final String MAIL_QUEUE_NAME = "mail.queue";
    public static final String MAIL_EXCHANGE_NAME = "mail.exchange";
    public static final String MAIL_ROUTING_KEY_NAME = "mail.routing.key";

    public static final String TRIGGER_GROUP_SUFFIX = "-Trigger-Group";
    public static final String JOB_GROUP_SUFFIX = "-Job-Group";

    private static String rootPath() {
        return TopLabsUtils.getFilePath(Constants.STRING_EMPTY, true);
    }
}
